package com.suian.spring.aop.interceptor;

import com.suian.spring.aop.MethodInterceptor;
import com.suian.spring.aop.MethodInvocation;

//日志拦截器
public class LogInterceptor implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        System.out.println("[Log] Before: " + invocation.getMethod().getName());
        try {
            Object result = invocation.proceed();
            System.out.println("[Log] After: " + invocation.getMethod().getName());
            return result;
        } catch (Exception e) {
            System.out.println("[Log] Exception: " + e.getMessage());
            throw e;
        }
    }
}
